<template>
  <div class="app-container2">
    <!--工具栏-->
    <div class="head-container">
      <content-block label="查询条件">

        <el-form :model="searchForm" label-width="100px" class="search-form">
          <el-row>
            <el-col :span="8">
              <el-form-item label="人员编号">
                <person-rpc ref="personRpc" @personRpcCallBack="personRpcCallBack" />
              </el-form-item>
            </el-col>
            <el-col :span="6" class="text-right" >
              <el-form-item>
                <el-button type="primary" @click="search">查询</el-button>
                <el-button @click="resetQuery">重置</el-button>
              </el-form-item>
            </el-col>

          </el-row>
        </el-form>

        <el-button
          class="filter-item"
          size="mini"
          type="primary"
          icon="el-icon-plus"
          @click="toPreview"
        >
          预览
        </el-button>

        <el-button
          class="filter-item"
          size="mini"
          type="primary"
          icon="el-icon-plus"
          @click="toSave"
        >
          新增
        </el-button>
      </content-block>

      <!--表格渲染-->
      <content-block label="职业年金联系函信息">
        <el-form ref="lxhForm" :model="lxhForm" label-width="210px" class="search-form">
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="转入地行政区划代码" :rules="[ { required: true, message: '转入地行政区划代码不能为空'},]">
                <fixed-region-tree-select v-model="lxhForm.aab301"  @change="handleRegionChange" />
              </el-form-item>
            </el-col>
            <!--              <el-col :span="8">-->
            <!--                <el-form-item label="转出地行政区划代码" :rules="[ { required: true, message: '转出地行政区划代码不能为空'},]">-->
            <!--                  <el-input v-model="lxhForm.aab299"></el-input>-->
            <!--                </el-form-item>-->
            <!--              </el-col>-->
            <el-col :span="8">
              <el-form-item label="联系函编号" >
                <el-input v-model="lxhForm.aae270"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="原个人编号" >
                <el-input v-model="lxhForm.aac319"></el-input>
              </el-form-item>
            </el-col>


            <el-col :span="8">
              <el-form-item label="转入地社保机构银行行号" :rules="[ { required: true, message: '转入地社保机构银行行号不能为空'},]">
                <el-input v-model="lxhForm.aac080"></el-input>
              </el-form-item>
            </el-col>


            <el-col :span="8">
              <el-form-item label="转入地社保机构开户银行名称" :rules="[ { required: true, message: '转入地社保机构开户银行名称不能为空'},]">
                <el-input v-model="lxhForm.aac155"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="转入地社保机构开户全称" :rules="[ { required: true, message: '转入地社保机构开户全称不能为空'},]">
                <el-input v-model="lxhForm.aae009"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="转入地社保机构银行账号" :rules="[ { required: true, message: '转入地社保机构银行账号不能为空'},]">
                <el-input v-model="lxhForm.aac078"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="转入地社保机构邮政编码" :rules="[ { required: true, message: '转入地社保机构邮政编码不能为空'},]">
                <el-input v-model="lxhForm.aae007"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="转入地社保机构地址" :rules="[ { required: true, message: '转入地社保机构地址不能为空'},]">
                <el-input v-model="lxhForm.aae006"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="转入地社保机构联系电话" :rules="[ { required: true, message: '转入地社保机构联系电话不能为空'},]">
                <el-input v-model="lxhForm.aae005"></el-input>
              </el-form-item>
            </el-col>

          </el-row>
        </el-form>


      </content-block>

      <content-block label="职业年金信息表信息">
        <el-form ref="xxbForm" :model="xxbForm" label-width="210px" class="search-form" disabled>
          <el-row :gutter="20">
            <el-col :span="8">
              <el-form-item label="个人编号" :rules="[ { required: true, message: '个人编号'},]">
                <el-input v-model="xxbForm.aac001"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="姓名" :rules="[ { required: true, message: '姓名'},]">
                <el-input v-model="xxbForm.aac003"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="性别" :rules="[ { required: true, message: '性别'},]">
                <el-input v-model="xxbForm.aac004"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="出生日期" :rules="[ { required: true, message: '出生日期'},]">
                <el-input v-model="xxbForm.aac006"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="身份证号码" :rules="[ { required: true, message: '身份证号码'},]">
                <el-input v-model="xxbForm.aac002"></el-input>
              </el-form-item>
            </el-col>


            <el-col :span="8">
              <el-form-item label="户籍地址" :rules="[ { required: true, message: '户籍地址'},]">
                <el-input v-model="xxbForm.aac010"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="转出单位名称" :rules="[ { required: true, message: '转出单位名称'},]">
                <el-input v-model="xxbForm.aab300"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="职业年金总额" :rules="[ { required: true, message: '职业年金总额'},]">
                <el-input v-model="xxbForm.aie074"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="记账金额" :rules="[ { required: true, message: '记账金额'},]">
                <el-input v-model="xxbForm.aae240"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="实账金额" :rules="[ { required: true, message: '实账金额'},]">
                <el-input v-model="xxbForm.aae252"></el-input>
              </el-form-item>
            </el-col>

            <el-col :span="8">
              <el-form-item label="补记的职业年金金额" :rules="[ { required: true, message: '补记的职业年金金额'},]">
                <el-input v-model="xxbForm.aic290"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="改革前试点划转金额" :rules="[ { required: true, message: '改革前试点划转金额'},]">
                <el-input v-model="xxbForm.aic005"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="企业年金金额" :rules="[ { required: true, message: '企业年金金额'},]">
                <el-input v-model="xxbForm.aae019"></el-input>
              </el-form-item>
            </el-col>

          </el-row>
        </el-form>


      </content-block>
    </div>
  </div>
</template>

<script>
import ic60js from '@/views/ynsb_comm/ic60/js/transferIc60'

import contentBlock from '@/components/labers/contentBlock.vue'
import PersonRpc from '@/views/ynsb_comm/comm/module/personRpc.vue'
import crudBasicAc01 from '@/views/ynsb_comm/ac01/basicAc01'
import crudAccountId40 from '@/views/ynsb_comm/id40/js/accountId40'
import api from '@/views/ynsb_comm/transferOut/js/api'
import FixedRegionTreeSelect from '@/components/labers/FixedRegionTreeSelect.vue'

export default {
  name: 'AccountIc58',
  components: { FixedRegionTreeSelect, PersonRpc, contentBlock },
  dicts: ['aic113', ''],
  data() {
    return {

      searchForm: {
        aac001: '', // 人员编号
        aac003: '', // 姓名
      },

      lxhForm: {
        aab301: '',
        aab299: '',
        aae270: '',
        aac319: '',
        aic113: '',
        aac080: '',
        aac155: '',
        aae009: '',
        aac078: '',
        aae007: '',
        aae006: '',
        aae005: '',
      },

      xxbForm: {
        aac001: '',
        aac003: '',
        aac004: '',
        aac006: '',
        aac002: '',
        aac010: '',
        aab300: '',
        aie074: '',
        aae240: '',
        aae252: '',
        aic290: '',
        aic005: '',
        aae019: '',
      },
      aaz159:"",
      aac001:"",
    }
  },
  methods: {

    personRpcCallBack(item) {
      this.searchForm = {
        aac001: item.aac001,
        aac003: item.aac003
      }
    },
    search() {
      // 假设查询的数据
      if (this.searchForm.aac001 !== '' && this.searchForm.aac001 !== null) {
        crudBasicAc01.getAc01Ac02({ ...this.searchForm }).then(res => {
          this.cardPerson=res
          let filteredValues = this.cardPerson.filter(item => item.aae140 === "180" && item.aac008==='1')
          if(filteredValues.length==0){
            this.$message('未查询到该人员职业年金有效参保信息');
            return
          }
          this.aaz159=filteredValues[0].aaz159
          this.aac001=filteredValues[0].aac001

          })

        }
      },

    handleRegionChange(value) {
      this.lxhForm = {}
      api.getaAftt({aab301:value,aic113:"9"}).then(res => {
        this.lxhForm = res[0]

      })
    },

    toPreview(){

          let data=this.lxhForm
          data.aaz159=this.aaz159
          data.aac001=this.aac001
          data.aic113="9"

        api.transferOutPreview(JSON.stringify(data)).then(res => {
          this.xxbForm=res.information
          })


    },

    toSave(){
      this.$refs.id40form.validate(valid => {
        if (valid) {

          let data=this.id40form
          data.aaz159=this.aaz159
          data.aac001=this.aac001

          crudAccountId40.add(JSON.stringify(data)).then(res => {
            this.$notify({
              title: '保存成功',
              type: 'success'
            });
            this.dialog_id40=false
            this.toQuery()
          })

        }
      });

    },

    resetQuery(){
      this.searchForm={}
    },


  }
}
</script>

<style scoped>

</style>
